package com.fingard.dsp.bank.reqrespobj.downloadreceipt;

import com.fingard.constant.Format;
import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.xml.XmlTextWriter;

public class RetAtsReceipt extends RetAtsBase {

    public String respCode;
    public String respInfo;
    public String dataFilePath;
    public String isSharedDir;

    public RetAtsReceipt(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();
    }

    public void writeRetToATS() {
    	writeRetBeforeDt();
        writeEnd();//写结束
    }
    
    private void writeRetBeforeDt(){
    	if(!hasWrittenRespCode){
	    	writeStart();//写返回ATS的统一头部信息
	        retXmlWriter.writeElementString("RespCode", respCode);
	        retXmlWriter.writeElementString("RespInfo", respInfo);
	        retXmlWriter.writeElementString("DataFilePath", dataFilePath);
	        retXmlWriter.writeElementString("IsSharedDir", isSharedDir);
	        hasWrittenRespCode = true;
    	}
    }
    

	public void writeRetDetail(RetAtsReceiptDetail pDetail){
		if(!hasWrittenRespCode){
			writeRetBeforeDt();
		}
		retXmlWriter.writeStartElement("DetailRecord");
		retXmlWriter.writeElementString("UniqueCode", pDetail.istNbr);
		retXmlWriter.writeElementString("ReceiptNo", pDetail.receiptNo);
		retXmlWriter.writeElementString("BusDate", Format.Date10Format.format(pDetail.busDate));
		retXmlWriter.writeElementString("BusRef", pDetail.busRef);
		retXmlWriter.writeElementString("Cur", pDetail.cur);
		retXmlWriter.writeElementString("TranCode", pDetail.tranCode);
		retXmlWriter.writeElementString("ReceiptType", pDetail.receiptType);
		retXmlWriter.writeElementString("OppActName", pDetail.oppActName);
		retXmlWriter.writeElementString("OppActNum", pDetail.oppActNum);
		retXmlWriter.writeElementString("MoneyWay", pDetail.moneyWay);
		retXmlWriter.writeElementString("Amount", pDetail.amount);
		retXmlWriter.writeElementString("Summary", pDetail.summary);
		retXmlWriter.writeElementString("UpFile", pDetail.upFile);
		retXmlWriter.writeEndElement();
	}
	
}
